//
//  ItemTool.m
//  微博2期
//
//  Created by J on 15/11/19.
//
//

#import "ItemTool.h"

@implementation ItemTool


/**
 *  创建一个item
 *
 *  @param action         点击item调用的方法
 *  @param image          图片
 *  @param hilightedImage 高亮的图片
 *
 *  @return 返回的item
 */
+ (UIBarButtonItem*)itemWithTarget:(id)target action:(SEL)action image:(NSString*)image highImage:(NSString*)hilightedImage{
    
    //设置右边更多按钮
    UIButton * button =[UIButton buttonWithType:UIButtonTypeCustom] ;
    [button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    [button setBackgroundImage:[UIImage imageNamed:image] forState:UIControlStateNormal];
    [button setBackgroundImage:[UIImage imageNamed:hilightedImage] forState:UIControlStateHighlighted];
    button.size = button.currentBackgroundImage.size;//普通状态下图片 x,y设置多少都无用
    return [[UIBarButtonItem alloc]initWithCustomView:button];
    
    
}

@end
